package com.dingreading.cloud.ssxcx.service.impl;

import com.dingreading.cloud.ssxcx.entity.Cmsubjects;
import com.dingreading.cloud.ssxcx.entity.table.CmsubjectsTableDef;
import com.dingreading.cloud.ssxcx.mapper.CmsubjectsMapper;
import com.dingreading.cloud.ssxcx.service.CmsubjectsService;
import com.mybatisflex.core.query.QueryCondition;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

/**
 * 科目信息表 服务层实现。
 *
 * @author EDY
 * @since 2025-08-11
 */
@Service
public class CmsubjectsServiceImpl extends BaseServiceImpl<CmsubjectsMapper, Cmsubjects, CmsubjectsTableDef> implements CmsubjectsService {

    @Override
    protected CmsubjectsTableDef getTable() {
        return CmsubjectsTableDef.cmsubjects;
    }

    @Override
    public List<Cmsubjects> getByProjectUids(Set<String> projectUids) {
        QueryCondition condition = QueryCondition.createEmpty()
                .and(table.uid.in(projectUids))
                .and(table.isPay.eq(1))
                .and(table.enabled.eq(1));
        return getMapper().selectListByCondition(condition);
    }

    @Override
    public Cmsubjects getBySubjectUid(String subjectUid) {
        return getMapper().selectOneByCondition(table.subjectUid.eq(subjectUid));
    }
}
